<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/6/22
  Time: 17:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<base href="<%=request.getContextPath()%>/">

<html>

<head> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <link rel="shortcut icon" href="img/favicon.ico" />
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="font-awesome/css/font-awesome.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
    <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>神舟Wifi管理系统</title>

</head>

<body class="gray-bg" οnlοad='init()'>

<c:if test="${null!=errorMsg}">
    <%--<% if(null!=request.getSession().getAttribute("errorMsg")) {    %>--%>
    <script type="text/javascript">
       {  swal('登录出错',"${errorMsg}", 'error');}
    </script>
</c:if>

<!-- 模态框（Modal） -->
<div class="modal fade" id="forgetPwd" tabindex="-1" role="dialog" aria-labelledby="myModalForget" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalForget">忘记密码</h4>
            </div>
            <div class="modal-body">
                <form id="forgetPFrom">
                    <div class="form-group">
                        <label for="idf">id</label>
                        <input type="text" class="form-control" id="idf" name="idf" placeholder="id"
                               required="">
                    </div>
                    <div class="form-group">
                        <label for="usernamef">用户名</label>
                        <input type="text" class="form-control" id="usernamef" name="usernamef" placeholder="用户名"
                               required="">
                    </div>
                    <div class="form-group">
                        <label for="passwordf">新密码</label>
                        <input type="password" class="form-control" id="passwordf" name="passwordf"
                               placeholder="密码" required="">
                    </div>
                    <div class="form-group">
                        <label for="passwordfconf">确认密码</label>
                        <input type="password" class="form-control" id="passwordfconf" name="passwordfconf"
                               placeholder="确认密码" required="">
                    </div>
                    <button type="button" class="btn btn-danger" onclick="forgetPwd()">提交</button>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>


<div class="middle-box text-center loginscreen animated fadeInDown">
  <div>
    <br class="text-center" >

      <img src="img/huawei.png" style="width:300px;height:250px;">
              </div>
    <h3>欢迎来到鸿蒙-神舟wifi管理界面</h3>
    <p>完美的设计，优秀的ui，只为最爵士的你。
    </p>
    <p>登录，开启你的爵士人生。</p>


    <form class="m-t" role="form" method="post" action="login">
      <div class="form-group " >
        <input type="text" class="form-control  " placeholder="用户名" required="" name="username" id="username" value="root">
      </div>
      <div class="form-group">
        <input type="password" class="form-control " placeholder="密钥" required="" name="password" id="password" value="root">
      </div>
      <button type="submit" class="btn btn-primary block full-width m-b">登录</button>

      <a   data-toggle="modal" data-target="#forgetPwd"><small>忘记密码?</small></a>
      <p class="text-muted text-center"><small>还不是爵士?</small></p>
      <a class="btn btn-sm btn-white btn-block"  data-toggle="modal" data-target="#addumode">注册一个爵士账户</a>
    </form>
    <p class="m-t"> <small>base on Bootstrap 3，国家机密，禁止商用 &copy; 2021</small> </p>
  </div>


<div class="modal fade" id="addumode" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">注册</h4>
            </div>
            <div class="modal-body">
                <form id="adduser">
                    <div class="form-group">
                        <label for="usernamel">用户名</label>
                        <input type="text" class="form-control" id="usernamel" name="usernamel" placeholder="用户名"
                               required="">
                    </div>
                    <div class="form-group">
                        <label for="passwordl">密码</label>
                        <input type="password" class="form-control" id="passwordl" name="passwordl"
                               placeholder="密码" required="">
                    </div>
                    <div class="form-group">
                    <label for="passwordlconf">确认密码</label>
                    <input type="password" class="form-control" id="passwordlconf" name="passwordlconf"
                           placeholder="确认密码" required="">
            </div>
                    <button type="button" class="btn btn-danger" onclick="adduser()">添加</button>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" >关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<script>
    function adduser(){
        url="user/signup?" + $("#adduser").serialize();
        console.log(url);
        $.post(url,{},function (data){
            if (data == 2) {
                swal('创建有误', "用户名或密码未输入", 'error');
            }
            if (data == 1) {
                swal('成功', "添加用户成功", 'success',{
                    button: "成为爵士",
                });
            }
            if (data == 3) {
                swal('添加失败', "请联系管理员或重试", 'error');
            }
            if (data == 4) {
                swal('添加失败', "用户已存在", 'error')
        }  if (data == 5) {
                swal('添加失败', "两次输入密码不一致", 'error')}},"json")
    }


   function forgetPwd(){
       url="user/getPwd?" + $("#forgetPFrom").serialize();

       $.post(url,{},function (data){
    console.log(data);
    if (data == 2) {
        swal('字段未填', "用户名或id未输入", 'error');
    }
    if (data == 1) {
        swal('成功', "修改密码成功", 'success',{
            button: "芜湖起飞",
        });
    }
    if (data == 3) {
        swal('字段未填', "请输入密码或确认密码", 'error');
    }
    if (data == 4) {
        swal('修改失败', "请确认id和用户名是否正确", 'error')
    }  if (data == 5) {
        swal('验证错误', "两次输入密码不一致", 'warning')}},"json")
   }

</script>

<!-- Mainly scripts -->
<script src="js/jquery-2.1.1.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>

</html>
